// Decompiled by GOOSIN CO,LTD Copyright 2010 Pavel Kouznetsov.
// home page: http://www.Goosin.net
// Decompiler options: packimports(3) fieldsfirst ansi space 
// Source File Name:   check_ok.java

package hr.bonus;

import include.get_sql.getInsertSql;
import include.nseer_cookie.exchange;
import include.nseer_db.nseer_db_backup1;
import java.io.IOException;
import java.io.PrintWriter;
import java.sql.ResultSet;
import java.util.StringTokenizer;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.http.*;
import javax.servlet.jsp.JspFactory;
import validata.ValidataNumber;

public class check_ok extends HttpServlet
{

	ServletContext application;
	HttpSession session;
	nseer_db_backup1 erp_db;

	public check_ok()
	{
		erp_db = null;
	}

	public synchronized void service(HttpServletRequest request, HttpServletResponse response)
		throws IOException, ServletException
	{
		HttpSession dbSession = request.getSession();
		JspFactory _jspxFactory = JspFactory.getDefaultFactory();
		javax.servlet.jsp.PageContext pageContext = _jspxFactory.getPageContext(this, request, response, "", true, 8192, true);
		ServletContext dbApplication = dbSession.getServletContext();
		try
		{
			HttpSession session = request.getSession();
			PrintWriter out = response.getWriter();
			nseer_db_backup1 hr_db = new nseer_db_backup1(dbApplication);
			if (hr_db.conn((String)dbSession.getAttribute("unit_db_name")))
			{
				getInsertSql getInsertSql = new getInsertSql();
				ValidataNumber validata = new ValidataNumber();
				String human_ID = request.getParameter("human_ID");
				String config_id = request.getParameter("config_id");
				String bonus_time = request.getParameter("bonus_time");
				String sql6 = (new StringBuilder("select id from hr_workflow where object_ID='")).append(human_ID).append("' and bonus_time='").append(bonus_time).append("' and type_id='06' and ((check_tag='0' and config_id<'").append(config_id).append("') or (check_tag='1' and config_id='").append(config_id).append("'))").toString();
				ResultSet rs6 = hr_db.executeQuery(sql6);
				if (!rs6.next())
				{
					String checker = request.getParameter("checker");
					String checker_ID = request.getParameter("checker_ID");
					String check_time = request.getParameter("check_time");
					String major_first_kind_ID = "";
					String major_first_kind_name = "";
					String major_second_kind_ID = "";
					String major_second_kind_name = "";
					String major_first_kind = request.getParameter("human_major_first_kind");
					for (StringTokenizer tokenTO4 = new StringTokenizer(major_first_kind, "/"); tokenTO4.hasMoreTokens();)
					{
						major_first_kind_ID = tokenTO4.nextToken();
						major_first_kind_name = tokenTO4.nextToken();
					}

					String major_second_kind = request.getParameter("human_major_second_kind");
					for (StringTokenizer tokenTO5 = new StringTokenizer(major_second_kind, "/"); tokenTO5.hasMoreTokens();)
					{
						major_second_kind_ID = tokenTO5.nextToken();
						major_second_kind_name = tokenTO5.nextToken();
					}

					String bodyb = new String(request.getParameter("remark").getBytes("UTF-8"), "UTF-8");
					String remark = exchange.toHtml(bodyb);
					String bonus_worth2 = request.getParameter("bonus_worth");
					if (bonus_worth2.equals(""))
						bonus_worth2 = "0";
					String bonus_worth = "";
					for (StringTokenizer tokenTO = new StringTokenizer(bonus_worth2, ","); tokenTO.hasMoreTokens();)
						bonus_worth = (new StringBuilder(String.valueOf(bonus_worth))).append(tokenTO.nextToken()).toString();

					String bonus_amount = request.getParameter("bonus_amount");
					int bonus_amount1 = Integer.parseInt(bonus_amount) + 1;
					String column_group = getInsertSql.sql((String)dbSession.getAttribute("unit_db_name"), "hr_file");
					String lately_change_time = request.getParameter("lately_change_time");
					String file_change_amount = request.getParameter("file_change_amount");
					int file_change_amount1 = Integer.parseInt(file_change_amount) + 1;
					String sql8 = (new StringBuilder("select * from hr_bonus where human_ID='")).append(human_ID).append("' and check_tag='0'").toString();
					ResultSet rs8 = hr_db.executeQuery(sql8);
					if (rs8.next())
					{
						if (validata.validata(bonus_worth))
						{
							try
							{
								String sql2 = (new StringBuilder("update hr_bonus set bonus_worth='")).append(bonus_worth).append("',checker='").append(checker).append("',check_time='").append(check_time).append("',remark='").append(remark).append("' where human_ID='").append(human_ID).append("' and check_tag='0'").toString();
								hr_db.executeUpdate(sql2);
								String sql = (new StringBuilder("update hr_workflow set checker='")).append(checker).append("',checker_ID='").append(checker_ID).append("',check_time='").append(check_time).append("',check_tag='1' where object_ID='").append(human_ID).append("' and bonus_time='").append(bonus_time).append("' and config_id='").append(config_id).append("' and type_id='06'").toString();
								hr_db.executeUpdate(sql);
								sql = (new StringBuilder("select id from hr_workflow where object_ID='")).append(human_ID).append("' and bonus_time='").append(bonus_time).append("' and check_tag='0' and type_id='06'").toString();
								ResultSet rset = hr_db.executeQuery(sql);
								if (!rset.next())
								{
									sql = (new StringBuilder("update hr_bonus set check_tag='1' where human_ID='")).append(human_ID).append("' and check_tag='0'").toString();
									hr_db.executeUpdate(sql);
									sql = (new StringBuilder("select * from hr_file where human_ID='")).append(human_ID).append("'").toString();
									ResultSet rs = hr_db.executeQuery(sql);
									if (rs.next())
									{
										String sqll = (new StringBuilder("insert into hr_file_dig(chain_id,chain_name,HUMAN_ID,HUMAN_NAME,HUMAN_ADDRESS,HUMAN_POSTCODE,HUMAN_TITLE_CLASS,HUMAN_MAJOR_FIRST_KIND_ID,HUMAN_MAJOR_FIRST_KIND_NAME,HUMAN_MAJOR_SECOND_KIND_ID,HUMAN_MAJOR_SECOND_KIND_NAME,HUMAN_BANK,HUMAN_ACCOUNT,HUMAN_TEL,HUMAN_HOME_TEL,HUMAN_CELLPHONE,HUMAN_EMAIL,HOBBY,SPECIALITY,SEX,RELIGION,PARTY,NATIONALITY,RACE,BIRTHDAY,BIRTHPLACE,AGE,EDUCATED_DEGREE,EDUCATED_YEARS,EDUCATED_MAJOR,SIN,IDCARD,MAJOR_TYPE,SALARY_STANDARD_ID,SALARY_STANDARD_NAME,SALARY_SUM,DEMAND_SALARY_SUM,PAID_SALARY_SUM,MAJOR_CHANGE_AMOUNT,BONUS_AMOUNT,TRAINING_AMOUNT,HISTORY_RECORDS,FAMILY_MEMBERSHIP,REMARK,PICTURE,ATTACHMENT_NAME,CHECK_TAG,FILE_CHANGE_AMOUNT,REGISTER,CHECKER,CHANGER,REGISTER_ID,CHECKER_ID,CHANGER_ID,REGISTER_TIME,CHECK_TIME,CHANGE_TIME,LATELY_CHANGE_TIME,DELETE_TIME,RECOVERY_TIME,EXCEL_TAG,CHANGE_TAG,MAJOR_CHANGE_TAG,TRAINING_CHECK_TAG,BONUS_CHECK_TAG,LICENSE_TAG) values('")).append(rs.getString("chain_id")).append("','").append(rs.getString("chain_name")).append("','").append(rs.getString("HUMAN_ID")).append("','").append(rs.getString("HUMAN_NAME")).append("','").append(rs.getString("HUMAN_ADDRESS")).append("','").append(rs.getString("HUMAN_POSTCODE")).append("','").append(rs.getString("HUMAN_TITLE_CLASS")).append("','").append(rs.getString("HUMAN_MAJOR_FIRST_KIND_ID")).append("','").append(rs.getString("HUMAN_MAJOR_FIRST_KIND_NAME")).append("','").append(rs.getString("HUMAN_MAJOR_SECOND_KIND_ID")).append("','").append(rs.getString("HUMAN_MAJOR_SECOND_KIND_NAME")).append("','").append(rs.getString("HUMAN_BANK")).append("','").append(rs.getString("HUMAN_ACCOUNT")).append("','").append(rs.getString("HUMAN_TEL")).append("','").append(rs.getString("HUMAN_HOME_TEL")).append("','").append(rs.getString("HUMAN_CELLPHONE")).append("','").append(rs.getString("HUMAN_EMAIL")).append("','").append(rs.getString("HOBBY")).append("','").append(rs.getString("SPECIALITY")).append("','").append(rs.getString("SEX")).append("','").append(rs.getString("RELIGION")).append("','").append(rs.getString("PARTY")).append("','").append(rs.getString("NATIONALITY")).append("','").append(rs.getString("RACE")).append("','").append(rs.getString("BIRTHDAY")).append("','").append(rs.getString("BIRTHPLACE")).append("','").append(rs.getString("AGE")).append("','").append(rs.getString("EDUCATED_DEGREE")).append("','").append(rs.getString("EDUCATED_YEARS")).append("','").append(rs.getString("EDUCATED_MAJOR")).append("','").append(rs.getString("SIN")).append("','").append(rs.getString("IDCARD")).append("','").append(rs.getString("MAJOR_TYPE")).append("','").append(rs.getString("SALARY_STANDARD_ID")).append("','").append(rs.getString("SALARY_STANDARD_NAME")).append("','").append(rs.getString("SALARY_SUM")).append("','").append(rs.getString("DEMAND_SALARY_SUM")).append("','").append(rs.getString("PAID_SALARY_SUM")).append("','").append(rs.getString("MAJOR_CHANGE_AMOUNT")).append("','").append(rs.getString("BONUS_AMOUNT")).append("','").append(rs.getString("TRAINING_AMOUNT")).append("','").append(rs.getString("HISTORY_RECORDS")).append("','").append(rs.getString("FAMILY_MEMBERSHIP")).append("','").append(rs.getString("REMARK")).append("','").append(rs.getString("PICTURE")).append("','").append(rs.getString("ATTACHMENT_NAME")).append("','").append(rs.getString("CHECK_TAG")).append("','").append(rs.getString("FILE_CHANGE_AMOUNT")).append("','").append(rs.getString("REGISTER")).append("','").append(rs.getString("CHECKER")).append("','").append(rs.getString("CHANGER")).append("','").append(rs.getString("REGISTER_ID")).append("','").append(rs.getString("CHECKER_ID")).append("','").append(rs.getString("CHANGER_ID")).append("','").append(rs.getString("REGISTER_TIME")).append("','").append(rs.getString("CHECK_TIME")).append("','").append(rs.getString("CHANGE_TIME")).append("','").append(rs.getString("LATELY_CHANGE_TIME")).append("','").append(rs.getString("DELETE_TIME")).append("','").append(rs.getString("RECOVERY_TIME")).append("','").append(rs.getString("EXCEL_TAG")).append("','").append(rs.getString("CHANGE_TAG")).append("','").append(rs.getString("MAJOR_CHANGE_TAG")).append("','").append(rs.getString("TRAINING_CHECK_TAG")).append("','").append(rs.getString("BONUS_CHECK_TAG")).append("','").append(rs.getString("LICENSE_TAG")).append("')").toString();
										hr_db.executeUpdate(sqll);
									}
									String sql3 = (new StringBuilder("update hr_file set lately_change_time='")).append(lately_change_time).append("',change_time='").append(check_time).append("',file_change_amount='").append(file_change_amount1).append("',bonus_amount='").append(bonus_amount1).append("',bonus_check_tag='0' where human_ID='").append(human_ID).append("'").toString();
									hr_db.executeUpdate(sql3);
								}
							}
							catch (Exception ex)
							{
								out.println((new StringBuilder("error")).append(ex).toString());
							}
							response.sendRedirect("hr/bonus/check_ok_a.jsp");
						} else
						{
							response.sendRedirect((new StringBuilder("hr/bonus/check_ok_b.jsp?human_ID=")).append(human_ID).toString());
						}
					} else
					{
						response.sendRedirect("hr/bonus/check_ok_c.jsp");
					}
				} else
				{
					response.sendRedirect("hr/bonus/check_ok.jsp?finished_tag=0");
				}
				hr_db.commit();
				hr_db.close();
			} else
			{
				response.sendRedirect("error_conn.htm");
			}
		}
		catch (Exception exception) { }
	}
}
